﻿#ifndef GRAPHICSWIDGET_H
#define GRAPHICSWIDGET_H

#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsScene>
#include "GraphicsAirValveItem.h"
#include "Graphics32ValveItem.h"
#include "Graphics42ValveItem.h"
#include "Graphics52ValveItem.h"
#include "GraphicsMFCItem.h"
#include "GraphicsVacuumPumpItem.h"

#include "OpcUA/opcua_qthread.h"
#include "OpcUA/plcdataconversion.h"

namespace Ui {
class GraphicsWidget;
}

class GraphicsWidget : public QWidget
{
    Q_OBJECT

public:
    explicit GraphicsWidget(QWidget *parent = nullptr);
    ~GraphicsWidget();

    void initOpcUA(OpcUA_QThread * OpcUA);

    void updateAllActualValue(double flowmeter[9], double pressuremeter[2], bool on[11]);

    void updateAllDesiredValue(double flowmeter[9], double pressuremeter[2]);

    void scaleRotateDemo();
    void valveItemDemo();
    void pixmapItemDemo();

 private slots:
    void on_mfcSetPointChanged(double value);
    void on_valveStateChanged(bool on);
    void on_pumpStateChanged(bool on);

    void initItems();
    void initButtons();
private:
    //void resizeEvent(QResizeEvent *event);    //写了这个代码，图像会不显示
    Ui::GraphicsWidget *ui;

    QGraphicsView * view;
    QGraphicsScene * scene;

    OpcUA_QThread * myOpcUA;

    //9个阀
    GraphicsAirValveItem * airValve[2];
    Graphics32ValveItem * air32Valve[2];

    Graphics42ValveItem *m_42Valve[2];

    Graphics52ValveItem * m_52Valve[4];

    //11个仪表，流量计与压力计设定
    GraphicsMFCItem * m_mfc[11];

    //泵
    GraphicsVacuumPumpItem * m_pump;
};

#endif // GRAPHICSWIDGET_H
